package com.stone.ble;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener {

	// private final static String UUID_KEY_DATA =
	// "0000fff0-0000-1000-8000-00805f9b34fb";
	private final static String TAG = "STONE";

	Context mcontext;

	ImageButton UI1_btn1;
	ImageButton UI1_btn2;
	ImageButton UI1_btn3;
	ImageButton UI1_btn4;
	ImageButton UI1_btn5;
	ImageButton UI1_btn6;
	ImageButton UI1_btn7;
	ImageButton UI1_btn8;
	private MySwitchButton mySwitchButton1;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		mcontext = this;
		UI1_btn1 = (ImageButton) findViewById(R.id.imageButton1);
		UI1_btn2 = (ImageButton) findViewById(R.id.imageButton2);
		UI1_btn3 = (ImageButton) findViewById(R.id.imageButton3);
		UI1_btn4 = (ImageButton) findViewById(R.id.imageButton4);
		UI1_btn5 = (ImageButton) findViewById(R.id.imageButton5);
		UI1_btn6 = (ImageButton) findViewById(R.id.imageButton6);
		UI1_btn7 = (ImageButton) findViewById(R.id.imageButton7);
		UI1_btn8 = (ImageButton) findViewById(R.id.imageButton8);
		mySwitchButton1 = (MySwitchButton) findViewById(R.id.my_switch_button1);
		mySwitchButton1.setImageResource(R.drawable.switch_bkg_switch,
				R.drawable.switch_btn_slip);

		UI1_btn1.setOnClickListener(this);
		UI1_btn2.setOnClickListener(this);
		UI1_btn3.setOnClickListener(this);
		UI1_btn4.setOnClickListener(this);
		UI1_btn5.setOnClickListener(this);
		UI1_btn6.setOnClickListener(this);
		UI1_btn7.setOnClickListener(this);
		UI1_btn8.setOnClickListener(this);

		// Use this check to determine whether BLE is supported on the device.
		// Then
		// you can selectively disable BLE-related features.
		if (!getPackageManager().hasSystemFeature(
				PackageManager.FEATURE_BLUETOOTH_LE)) {
			Toast.makeText(this, "��֧��Android 4.3���µ�ϵͳ�ֻ�",
					Toast.LENGTH_SHORT).show();
			UI1_btn1.setEnabled(false);
			UI1_btn2.setEnabled(false);
			UI1_btn3.setEnabled(false);
			UI1_btn4.setEnabled(false);
			UI1_btn5.setEnabled(false);
			UI1_btn6.setEnabled(false);
			UI1_btn7.setEnabled(false);
			UI1_btn8.setEnabled(false);
			finish();
			return;
		}
	}
	@Override
	public void onClick(View v) {
		int id = v.getId();
		Intent intent = new Intent(MainActivity.this, ControlActivity.class);
		switch (id) {
		case R.id.imageButton1:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_KETING);
			break;
		case R.id.imageButton2:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_ZHUWO);
			break;
		case R.id.imageButton3:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_CIWO_A);
			break;
		case R.id.imageButton4:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_CIWO_B);
			break;
		case R.id.imageButton5:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_CANTING);
			break;
		case R.id.imageButton6:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_CHUFANG);
			break;
		case R.id.imageButton7:
			intent.putExtra(DataModel.COLUMN_UI_TOP, MyConstants.UI_TOP_YANGTAI);
			break;
		case R.id.imageButton8:
			intent.putExtra(DataModel.COLUMN_UI_TOP,
					MyConstants.UI_TOP_WEISHENGJIAN);
			break;
		}
		startActivity(intent);
	}
}
